<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>猜数字</title>
</head>
<body>
    <button type="button" id="reset">重新开始一局游戏</button>
    <br/>
    请输入要猜的数字：<input type="text" id="number">
    <button type="button" id="button">猜</button>
    <br/>
    已经猜的次数：<span id="count"></span>
    <br/>
    结果：<span id="result"></span>
    <script src="js/jquery.min.js"></script>
    <script>
        $(function(){
            var num = Math.floor(Math.random()*100)+1;
            console.log(num)
            var count =0;
            $('#button').click(function(){
                
                var guessnumber=$('#number').val();
                count++;
                $('#count').text(count);

                if(num<guessnumber){
                    $("#result").text("猜大了")
                    $("#result").css("color","red")
                }else if(num>guessnumber){
                    $("#result").text("猜小了")
                    $("#result").css("color","red")
                }else{
                    $("#result").text("猜对了")
                    $("#result").css("color","green")
                }
            });

            $("#reset").click(function(){
                num = Math.floor(Math.random()*100)+1;
                console.log(num)
                count=0;
                $("#count").text(count);
                $("#result").text("");
                $("#number").val("");
            });
        })
    </script>
</body>
</html>